home *** CD-ROM | disk | FTP | other *** search
- Hi,
- i've just seen a message from Doug about the AI.
- i'll read it further tonight.
- here's an introduction file i've made. Waiting for comments...
- BTW, it's not finished, i'll keep it up to date.
-
- --------------------------------------------------------------------------
- Bad Mood - Basic Monster AI -
- Frederic Jaume 21.02.96 jaume@massilia.univ-mrs.fr
- With the help of Frederic Calendini
- Changes : 06.03.96
-
- here's just a first try, tell me what you think.
- There are a lot of question in the following document, so please
- answer them!
-
- Part one : the monsters and other things...
- First, we need to choose a data structure, and then to create the AI.
- thhen I 'll explain the method that can be used for the monsters movements.
- This method works! It's not very complex for the moment, but it's been used
- in a game (that was done by a friend of mine) on amiga, some sort of Zelda/Ultima
- adventure game that had to deal with monsters AI. Though, it was programmed in AMOS,
- and neither my friend nor i, can code in 68030, so you'll just find algorithms, and
- simple C code. Bad Mood deserves a more complex AI, but it's just
- a beginning.
-
- --------------------------------
-
- An inportant part of the AI is the data structures to be used.
-
- DATA STRUCTURES
-
- Al the 'Things' in the doom.wad's level chosen should be stored in an
- array. Each element of the array, each 'Thing' has :
- 1- x
- 2- y
- 3- facing angle
- 4- thing type
- 5- thing option
- (to be modified when our own Bad Mood Thing specs are done)
- And stored in a table should be also in memory the Things characterisic
- (i.e. Radius, Height, Mass, Tough, Speed, Sprite name or class of things)
- correspond to a special Thing Type.
-
- As Doug suggested, the use of linked list may be the more effective for
- knowing what 'Things' has to be dealt with.
- The list are built using the sector number.
- Let's say there are n sectors in the chosen levels. Then we create n lists
- of chained things (or rather chained pointers on elements of the Things
- array). And, when the player gets in sector x, the 'things' in the list x
- are used and treated.
-
- >>? Should we use the same sector numbering as the one used to build up
- levels, since there are a lot of them, and some of them will not have
- 'things' inside (the small ones).
-
- Now, 2 possibilities:
- (look at drawing) what if you are in 1 (then checking things in
- list1) ? We have to also check the things in 2 and 3 (they might see you,
- you might see them) [think also of monsters behind windows like in e1m1]
-
-
- |2|
- _______| |
- / |______
- | 3
- | ______
- | |
- | 1 |
- \__________/
-
- So, either we have 1 list for sector 1 that contains all the things
- in sector 1 but also contains the things from close sectors (2 and 3), and
- then we only check the list the player is in,
- or, we have in each list only the things of the sector which corresponds
- to the list, and we have top check multiple list each time, i.e. the list
- the player is in, and the list of the close sectors. (better for memory).
-
- If a monster changes sector (chasing you), he is removed from the list he
- belonged(involves a search), and added to the list of the new sector he is
- in).
- If a monster is killed, then he becomes an inanimate object (dead body).
- If a thing is taken (key, medicine) then it is removed from the list it
- belongs to.
-
- to be continued...
-
-
-
-
- THE AI - 'INVISIBLE FOOTPRINTS' METHOD
-
-
- - how does it work ?
- to simulate a realistic chase, we can use the "invisible footprints/trail"
- method, which is the following one:
- we've got an array of that type:
-
- typedef struct footprint { int x,y }
-
- struct footprint trail[max_number_of_footprints]
-
- let's say max_number_of_footprints=20, then we've got the 20 last positions
- of the player in memory all the time. What's the point?
-
- Well, here's the basic algorithm:
-
-
- loop
- {
- for i <- 0 to nb_things_in_current_sector
- begin
- if thing[i] is a monster then
- if this monster "sees" the player then
- monster steps toward the player
- if distance between monster and player is <= min_dist then fire!
- else
- repeat
- check each player_footprint (from new one to old one)
- if monster sees footprint, then he steps toward this position
- until (monster moved) or (all fooprints checked)
- /* if monsters doesn't see any footprints then monster stops */
- else: nothing
- end
- }
-
- an interesting point is that, with this method we can have an intelligence
- factor for each monster, which is in fact the ability of the monster to
- see a particular amount of footprints (dumb monsters won't see any, so if
- you just hide behind a wall, the dumb monsters think you disapeared, and
- go back to watch BayWatch...
-
-
- When a monster follows the player into a sector which is not his (this
- happens if the monster is not blocked by the Reject), then he is
- deleted from the list of the sector to which he belongs, and added to the
- list of the one he arrives in.
-
- Of course, this still makes dumb monsters, very easy to shoot, so
- they'll have to zig-zag to try to avoid your shooting, like in doom,
- maybe we can think of differents moves, using differents formulas so
- that all the monsters don't act the same way.
-
- And, can't the monster find you by the noise you make ( in the Mexican
- Food Inferno level...) ?
-
- I though about it, and i think we can do it by generating footprints all
- around the player (in every direction, in places that are step-able)
- whenever he uses a noisy weapon. But, then we need
- another structure for noise generated footprints (as when in chase mode we
- need an ordered list of footprints), so the foot-made footprints are
- checked first, and then the noise-prints second.
-
- And now for something completely different :
- What is needed:
- -thing-player collision
- -monster-sees-player function
- -sector-thing-is-in-function
- -speed optimization
-
- This is a cut version. I want some feed back!
- I've got some C code, too but it's not good enough at the moment.
-
- Bye!
- XxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxX
- X Information is not knowledge , knowledge is not wisdom X
- X Wisdom is not truth , thruth is not beauty X
- X Beauty is not Love , Love is not Music X
- X Music is the Best ! (Frank Zappa) X
- X X
- X Frederic JAUME ---> jaume@massilia.univ-mrs.fr X
- X Licence d'Informatique CMI Chateau-Gombert Marseille, FRANCE X
- XxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxX
-
-
-